package com.ibm.mall.action;


import java.util.HashMap;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ibm.mall.base.BaseAction;
import com.ibm.mall.model.Feedback;
import com.ibm.mall.model.PageBean;
import com.ibm.mall.util.QueryHelper;

@Controller
@Scope("prototype")
public class FeedbackAction extends BaseAction<Feedback> {
	
	private static final long serialVersionUID = 1L;
	
	private Map responseJson;
	
    public Map getResponseJson() {   
        return responseJson;   
    }
    
    public void setResponseJson(Map responseJson) {   
        this.responseJson = responseJson;   
    }
	
    public String list() {
		return "list";
	}

	public String delete(){
		Feedback feedback = feedbackService.getFeedbackById(model.getId());
		feedback.setStatus((short) 1);
		feedbackService.updateFeedback(feedback);
		return "delete";
	}
	
	public String deal(){
		Feedback feedback = feedbackService.getFeedbackById(model.getId());
		feedback.setFeedbackStatus((short) 1);
		feedbackService.updateFeedback(feedback);
		return "deal";
	}
	
	public String getData(){
        Map<String, Object> map = new HashMap<String, Object>();
        QueryHelper queryHelper=new QueryHelper(Feedback.class, "f")//
			.addCondition("f.status=?", (short)0)//查询出未被删除的
			.addOrderProperty("f.id", true);
        //分页查询获得pageBean
        PageBean pageBean=feedbackService.getPageBean(page,rows,queryHelper);
        map.put("rows", pageBean.getRecordList());
        map.put("total", pageBean.getRecordCount());
        this.setResponseJson(map);
        return "getData";
    }
}
